package com.itbaizhan.controller;

import com.itbaizhan.pojo.Address;
import com.itbaizhan.pojo.AddressList;
import com.itbaizhan.pojo.AddressMap;
import com.itbaizhan.pojo.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Arrays;
import java.util.Date;
import java.util.List;

@Controller
public class MyController1 {

    @RequestMapping("/c1/hello")
    public void helloMVC(){
        System.out.println("hello SpringMVC!");
    }

    @RequestMapping("/c1/param1")
    public void simpleParam(String username, int age){
        System.out.println(username);
        System.out.println(age);
    }

//    @RequestMapping("/c1/param2")
//    public void objectParam(Student student){
//        System.out.println(student);
//    }

    @RequestMapping("/c1/param2")
    public void objectParam(Student student){
        System.out.println(student);
    }

    @RequestMapping("/c1/param3")
    public void listParam(@RequestParam List<String> users){
        System.out.println(users);
    }

    @RequestMapping("/c1/param4")
    public void arrayParam(@RequestParam String[] users){
        System.out.println(Arrays.toString(users));
    }

    @RequestMapping("/c1/param5")
    public void objectListParam(AddressList addressList){
        System.out.println(addressList.getAddresses());
    }

    @RequestMapping("/c1/param6")
    public void objectMapParam(AddressMap addressMap){
        System.out.println(addressMap.getAddresses());
    }


    @RequestMapping("/c1/param7")
    public void dateParam(Date birthday){
        System.out.println(birthday);
    }


}
